package br.edu.univas.si.lab3.bankmanager.view;

import java.awt.Font;
import java.awt.Rectangle;

import javax.swing.JLabel;
import javax.swing.JPanel;

import br.edu.univas.si.lab3.bankmanager.model.ClienteTO;
import br.edu.univas.si.lab3.bankmanager.model.ContaTO;

public class PanelContaInfo extends JPanel{
	static final long serialVersionUID = 1L;

	private ContaTO conta;
	
	private JLabel saldo;
	private JLabel saldoInfo;
	
	private JLabel tipoContaInfo;
	
	private JLabel nome;
	private JLabel nomeInfo;
	
	private ClienteTO cliente;
	
	public PanelContaInfo(ContaTO conta, ClienteTO cliente) {
		this.conta = conta;
		this.cliente = cliente;
		setLayout(null);
		initialize();
	}

	private void initialize() {
		add(getTipoContaInfoLabel());
		
		add(getNameLabel());
		add(getNameInfoLabel());
		
		add(getSaldoLabel());
		add(getSaldoInfoLabel());
		
	}
	
	private JLabel getTipoContaInfoLabel(){
		if(tipoContaInfo == null){
			tipoContaInfo = new JLabel();
			tipoContaInfo.setText(conta.getTipoConta());
			tipoContaInfo.setBounds(new Rectangle(175, 15, 200, 16));
			tipoContaInfo.setFont(new Font("Times New Roman", Font.BOLD+Font.ITALIC, 16));
		}
		return tipoContaInfo;
	}
	
	private JLabel getNameLabel(){
		if(nome == null){
			nome = new JLabel("Cliente: ");
			nome.setBounds(new Rectangle(10, 45, 150, 16));
			nome.setFont(new Font("Times New Roman", Font.BOLD+Font.ITALIC, 16));
		}
		return nome;
	}
	
	private JLabel getNameInfoLabel(){
		if(nomeInfo == null){
			nomeInfo = new JLabel();
			nomeInfo.setText(cliente.getNome());
			nomeInfo.setBounds(new Rectangle(80, 45, 400, 16));
			nomeInfo.setFont(new Font("Times New Roman", Font.BOLD+Font.ITALIC, 16));
		}
		return nomeInfo;
	}
	
	private JLabel getSaldoLabel(){
		if(saldo == null){
			saldo = new JLabel("Saldo:");
			saldo.setBounds(new Rectangle(10, 75, 150, 16));
			saldo.setFont(new Font("Times New Roman", Font.BOLD+Font.ITALIC, 16));
		}
		return saldo;
	}
	
	private JLabel getSaldoInfoLabel(){
		if(saldoInfo == null){
			saldoInfo = new JLabel();
			if(conta.getSaldo() != -9999)
				saldoInfo.setText("R$ " + conta.getSaldo().toString());
			else
				saldoInfo.setText("R$ " + "0");
			saldoInfo.setBounds(new Rectangle(80, 75, 400, 16));
			saldoInfo.setFont(new Font("Times New Roman", Font.BOLD+Font.ITALIC, 16));
		}
		return saldoInfo;
	}
}
